<template>
  <svg
    :width="width"
    :height="height"
    :style="{ color: color }"
    class="svg-icon"
    aria-hidden="true"
  >
    <use :href="symbolId" :fill="color" />
  </svg>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  // svg文件名
  name: {
    type: String,
    required: true,
  },
  // svg宽度
  width: {
    type: [Number, String],
    default: '1em',
  },
  // svg高度
  height: {
    type: [Number, String],
    default: '1em',
  },
  // svg颜色
  color: {
    type: String,
    default: 'currentColor',
  },
})

const symbolId = computed(() => `#icon-${props.name}`)
</script>

<style scoped>
.svg-icon {
  vertical-align: -0.15em;
  overflow: hidden;
  fill: currentColor;
}
</style>
